package baocuntupian.com.idcard;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.google.gson.Gson;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import okhttp3.Call;

public class MainActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private Gson mGson=new Gson();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        recyclerView= (RecyclerView) findViewById(R.id.main_recy);
        OkHttpUtils.get()
                .url("http://apicloud.mob.com/idcard/query?cardno=140423199712090410&key=1d11feb940fe2")
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {

                        Log.e("TAG",response);
                        Bean bean = mGson.fromJson(response, Bean.class);
                        Bean.ResultBean t1348649145984 =bean.getResult();
                        recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false));
                        recyclerView.setAdapter(new MyRecyclerViewAdapter(MainActivity.this,t1348649145984));

                    }
                });
    }
}
